package com.laicunba.ext.web.controller.h5.activity;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.laicunba.ext.web.controller.BaseController;
import com.laicunba.pojo.RegistryDO;
import com.laicunba.service.RegistryService;
import com.laicunba.util.StringUtil;

@Controller
@RequestMapping(value = "/h5/ext/activity")
public class DownloadApp0324Controller extends BaseController {

	@Autowired
	private RegistryService registryService;

	@RequestMapping(value = "/download_app_0324_form.htm")
	public ModelAndView downloadApp0324Form() {
		ModelAndView view = new ModelAndView();
		view.setViewName("download_app_0324.jsp");
		return view;
	}

	@RequestMapping(value = "/download_app_0324.htm")
	public void downloadApp0324(HttpServletRequest request, HttpServletResponse response, String mobile) {
		if (!StringUtil.isMobileNumber(mobile)) {
			return;
		}
		if (registryService.get(RegistryDO.class, "act.0324." + mobile) == null) {
			registryService.create("act.0324." + mobile, mobile);
		}
		try {
			response.sendRedirect("http://a.app.qq.com/o/simple.jsp?pkgname=com.laicunba.licai&ckey=CK1360261798014");
		} catch (IOException e) {
		}

	}

}
